//
//  Config.swift
//  casdon_swiftUI
//
//  Created by casdon on 2025/4/2.
//

import Foundation

enum EnvironmentType: String {
    case dev, uat, prod
}

final class EnvironmentConfig {
    static let shared = EnvironmentConfig()
    
    var currentType: EnvironmentType {
        didSet {
            switchTo(currentType)
        }
    }
    
    private(set) var current: CDEnvironment
    
    private init() {
        currentType = .dev
        current = Environment_dev.shared
    }
    
    private func switchTo(_ environment: EnvironmentType) {
        // 这里你可以根据实际情况切换环境对象，如：
        switch environment {
        case .dev:
            current = Environment_dev.shared
            break
        case .uat:
            current = Environment_uat.shared
            break
        case .prod:
            current = Environment_prod.shared
            break
        }
    }
}

// MARK: - 协议
protocol CDEnvironment {
    var URL_MIFFY: String { get }
    var URL_MAIN: String { get }
    var URL_RY: String { get }
    var URL_Ciot_MAIN: String { get }
    var REQUEST_PUBLICKEY: String { get }
}
struct Environment_dev : CDEnvironment{
    static let shared = Environment_dev()
    private init() {}
    let URL_MIFFY = "https://casdon-api.casdon.com.cn/api"
    let URL_MAIN = "http://dev.casdon.com.cn:30888/api"
    let URL_RY = "https://www.openapi.casdon.com.cn/t/casdon/open/"
    /// ciot
    let URL_Ciot_MAIN = "http://172.16.230.1:31649"
    
    let REQUEST_PUBLICKEY =
        """
        -----BEGIN PUBLIC KEY-----
        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7e+JN7+bE2faSOqLUrVZkvcIqQqiUr5tE2dczrXLjw4yhe2aHxFI9sJlYQNT8r1VTETKjDv9BZQjx8SlnoatBFR/ZOMUAYeUKGqWv2AIw7nDs9GKsUcLliXmx+otocyH1SyZSJUoA6Jpe3YXfvSEkYUkEZYVWIWVvcWGQSOB+oO80qvI6n0ajJ0VrVudzVLSgcNX0wk5MnnzRB9kB3Z1VCmh+2IxfF+sH+gXSmeXRCZ20nbdDinwb7tBNfHYE9PTubaQJvCuckSbjuYILCKai6HMYr9102K1gB/HLMyCx7KnNppz4UV7XActK4tjeYX17FdQ+yq8WbaX3DWbiEVsQIDAQAB
        -----END PUBLIC KEY-----
        """
}

struct Environment_prod : CDEnvironment{
    static let shared = Environment_prod()
    private init() {}
    let URL_MIFFY = "https://casdon-api.casdon.com.cn/api"
    let URL_MAIN = "https://api.casdon.cloud/api"
    let URL_RY = "https://ap8-openapi.fscloud.com.cn/t/casdon/open/"
    let URL_Ciot_MAIN = "http://172.16.230.1:31649"
    
    let REQUEST_PUBLICKEY =
        """
        -----BEGIN PUBLIC KEY-----
        MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYYLfHULujSoFUHUUiF9m6DlMG/lu0bMUJSAluVWjWF9MSW38tlbwS3kLMFnRj4yQbTjhUpAv5JDv3h0F+IyJtw2/I3jnwYc/Nkvo6CO7mDNRkvtZzS8/i2dBiITG1oDhzxG+vsmCM3UE5YL8NOfTvupDX4k1lfnQkxQOChd2eyQIDAQAB
        -----END PUBLIC KEY-----
        """
}

struct Environment_uat : CDEnvironment{
    static let shared = Environment_uat()
    private init() {}
    let URL_MIFFY = "https://casdon-api.casdon.com.cn/api"
    let URL_MAIN = "http://dev.casdon.com.cn:30888/api"
    let URL_RY = "https://www.openapi.casdon.com.cn/t/casdon/open/"
    /// ciot
    let URL_Ciot_MAIN = "http://172.16.230.1:31649"
    
    let REQUEST_PUBLICKEY =
        """
        -----BEGIN PUBLIC KEY-----
        MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7e+JN7+bE2faSOqLUrVZkvcIqQqiUr5tE2dczrXLjw4yhe2aHxFI9sJlYQNT8r1VTETKjDv9BZQjx8SlnoatBFR/ZOMUAYeUKGqWv2AIw7nDs9GKsUcLliXmx+otocyH1SyZSJUoA6Jpe3YXfvSEkYUkEZYVWIWVvcWGQSOB+oO80qvI6n0ajJ0VrVudzVLSgcNX0wk5MnnzRB9kB3Z1VCmh+2IxfF+sH+gXSmeXRCZ20nbdDinwb7tBNfHYE9PTubaQJvCuckSbjuYILCKai6HMYr9102K1gB/HLMyCx7KnNppz4UV7XActK4tjeYX17FdQ+yq8WbaX3DWbiEVsQIDAQAB
        -----END PUBLIC KEY-----
        """
}



//测试环境
//publicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq7e+JN7+bE2faSOqLUrVZkvcIqQqiUr5tE2dczrXLjw4yhe2aHxFI9sJlYQNT8r1VTETKjDv9BZQjx8SlnoatBFR/ZOMUAYeUKGqWv2AIw7nDs9GKsUcLliXmx+otocyH1SyZSJUoA6Jpe3YXfvSEkYUkEZYVWIWVvcWGQSOB+oO80qvI6n0ajJ0VrVudzVLSgcNX0wk5MnnzRB9kB3Z1VCmh+2IxfF+sH+gXSmeXRCZ20nbdDinwb7tBNfHYE9PTubaQJvCuckSbjuYILCKai6HMYr9102K1gB/HLMyCx7KnNppz4UV7XActK4tjeYX17FdQ+yq8WbaX3DWbiEVsQIDAQAB


let APP_CLIENTID = "428a8310cd442757ae699df5d894f051"
// MARK: - 协议
let USER_PROTOCOL = "https://casdon-privacy.casdon.com.cn/agreement.html"
// 隐私协议
let PRIVACY_PROTOCOL = "https://casdon-privacy.casdon.com.cn/privacy.html"


let COUNTRY_CODE = "86"
let WECHAT_LOGIN_SOURCE = "wechat_open"
let APPLE_LOGIN_SOURCE = "appleid"
let WECHAT_UNISAL_LINK = "https://cloud.casdon.com.cn"
